CC=gcc
CFLAGS=-Wall -g
LDFLAGS=
EXEC=dns_server_v0 dns_server_v1 dns_server_v2 local_dns_server_v1 local_dns_server_v2 dns_client

all: $(EXEC)

dns_server_v0: dns_server_v0.o dns_packet_parsing.o dns_server_rr_files.o dns_util.o
	$(CC) -o $@ $^ $(LDFLAGS)

dns_server_v0.o: dns_packet_parsing.h dns_server_rr_files.h

dns_server_v1: dns_server_v1.o dns_packet_parsing.o dns_server_rr_files.o dns_util.o
	$(CC) -o $@ $^ $(LDFLAGS)

dns_server_v1.o: dns_packet_parsing.h dns_server_rr_files.h

dns_server_v2: dns_server_v2.o dns_packet_parsing.o dns_server_rr_files.o dns_util.o
	$(CC) -o $@ $^ $(LDFLAGS)

dns_server_v2.o: dns_packet_parsing.h dns_server_rr_files.h

local_dns_server_v1: local_dns_server_v1.o dns_packet_parsing.o dns_util.o local_dns_util.o
	$(CC) -o $@ $^ $(LDFLAGS)

local_dns_server_v1.o: dns_packet_parsing.h

local_dns_server_v2: local_dns_server_v2.o dns_packet_parsing.o dns_util.o local_dns_util.o
	$(CC) -o $@ $^ $(LDFLAGS)

local_dns_server_v2.o: dns_packet_parsing.h

dns_client: dns_client.o dns_packet_parsing.o dns_util.o
	$(CC) -o $@ $^ $(LDFLAGS)

dns_client.o: dns_packet_parsing.h

%.o: %.c
	$(CC) -o $@ -c $< $(CFLAGS)

.PHONY: clean mrproper

clean:
	rm -rf *.o

mrproper: clean
	rm -rf $(EXEC)
